package com.zhang.third.day02;

import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

/**
 * @title: min max sum  算子
 * @author: zhang
 * @date: 2022/4/2 15:49
 */
public class Example6 {
    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        env.setParallelism(1);

        env
                .fromElements(1, 2, 3, 4, 5, 6, 7)
                .keyBy(r -> r % 3)
                // 整数类型数值只有一个字段0
                .sum(0).setParallelism(4)
                .print().setParallelism(4);

        env
                .fromElements(1, 2, 3, 4)
                .keyBy(r -> 1)
                .min(0)
                .print("min");

        env
                .fromElements(1, 2, 3, 4, 5)
                .keyBy(r -> 1)
                .max(0)
                .print("max");

        env.execute();
    }
}
